Code separation with semantic guarantees

ABSTRACT

Techniques to perform code separation with semantic guarantees are described. When porting a software application to a different target architecture and potentially to a different set of platforms and programming languages, application functionality will change based at least to accommodate architectural differences. However, business logic should be guaranteed to be semantically preserved, efficiency optimized to the platform benefits and limitations. Code separation identifies candidate components, associates the candidate components with a component classification or type, and automates the determining of which of the candidate components are to be associated with various portions of the target architecture. Automated code separation may include various inference algorithms to determine which components are to be associated with a component type. Also described are various use cases for code separation.

BACKGROUND

Software applications, such as accounting, finance, and customer relations applications, may constitute a large, ongoing investment by an enterprise or other organization. For example, an enterprise information technology (“EIT”) organization may invest in the initial requirements gathering and design of an application. Then EIT may invest in the software programming, development and testing of the application. Next enterprise data will have to be entered or ported into the application. Finally the application will be deployed, often constituting an expense of both hardware and/or training.

As the application is used and modified during its lifecycle, the application accrues modifications and bug fixes, as well as an accretion of business unit information technology (“BUIT”) satellite applications. In this way, an ecosystem builds around the original software application. Eventually the application may become relied upon by the enterprise as the embodiment of the enterprise's policies. Thus, a software application not only represents a financial investment, but also an institutionalization of the enterprise's business procedures.

However, technology platforms evolve and business needs and policies evolve. An example of the former is where an initial investment in a two tier client server software architecture may give way to three tier enterprise data center based architectures which in turn evolve into web based applications and cloud based applications, each time causing applications to be ported to the newer software architectures. Another example of the former is where programming languages and frameworks become deprecated, such as where Microsoft Visual Basic.NET™ and the .NET application framework was not fully backwards compatible with Microsoft Visual Basic 6 and its Component Object Model based infrastructure, giving rise to applications being ported. An example of the latter is where the C Standard Library <string.h> library was later found to be susceptible to buffer overrun security attacks, causing applications to be moved to fixed buffer equivalents.

Typically, porting an application to a new software architecture, or platform causes a full rewrite. Since the rewrite is to a new architecture, or platform, or represents some other form of code refactoring, the port will not behave exactly in the same way as before. For example, a personal computer based client application may be ported to a mobile device. Accordingly, the functionality of the ported application on mobile device will differ at least according to the form factor change.

The functionality change causes risk that the semantics of the rewrite will not exactly conform to the behavior of the original application. If this were to happen, BUIT satellite applications and other software applications interfacing with the original application may break.

This state of affairs leaves EIT organizations on the horns of a dilemma. The extension of the lifecycle of their mission critical software applications may rely on a successful port to a new architecture or platform. But to do so, the EIT organization may have to risk a non-conforming port. In other words, the EIT organization cannot rely on semantics to be preserved during a port.

BRIEF DESCRIPTION OF THE DRAWINGS

The Detailed Description is set forth with reference to the accompanying figures. In the figures, the left-most digit(s) of a reference use of the same reference numbers in different figures indicates similar or identical items.

FIG. 1 is a top level context diagram for code separation with semantic guarantees.

FIG. 2 is a hardware diagram of an exemplary hardware and software platform for code separation with semantic guarantees.

FIG. 3 is a flowchart of an exemplary operation of a software application transformation using code separation with semantic guarantees.

FIG. 4 is a flowchart of an exemplary operation of inferring components during code separation with semantic guarantees.

FIG. 5 is a flowchart of an exemplary operation of an MVVM re-architecture using code separation with semantic guarantees.

DETAILED DESCRIPTION

Transformations, Code Separation and Semantic Guarantees

Components, Software Architectures and Component Types

This patent application discloses automated code transformations of software applications where the transformation includes separating the code into components corresponding to a target architecture while guaranteeing semantic equivalence. Specifically, modern software applications are generally organized into separate components. Components may be loosely or tightly coupled and may have high or low degrees of cohesion. Accordingly, components are not merely functional blocks of code, but also include an invocation interface where the interface guarantees specific semantic behavior. In object oriented programming, a component's invocation interface is sometimes referred to as a “contract” thereby emphasizing the guarantee of specific semantic behavior.

Components are not homogenous. Components typically take on specialized roles in interacting with other components. In this way, components may be organized into parts of a larger software machine. For example in object oriented programming, design patterns are component interaction patterns where a generic component type may be specialized according to a particular application. For instance, one design pattern is the strategy design pattern where an abstract class is replaced with a concrete class depending on the context of a situation. Thus concrete components may take on the type of an abstract class.

Design patterns typically apply only to a part of a software application. However, there are patterns, called software architectural patterns, that cover an enter software application. Example software architectural patterns are model-view-controller (“MVC”), model-view (“MV”), and model-view-viewmodel (“MVVM”). Software architecture design is often driven by a platform. Specifically, a platform is the set of hardware and/or software that hosts and executes the software. A platform generally comprises hardware, an operating system, standard libraries and/or a software application framework. In the case of a virtual execution environment, the platform may not necessarily specify physical hardware but virtual hardware and an execution environment or virtual machine. In this way a platform describes the support infrastructure for a software application. As a result, a platform may describe the hardware architecture and platform software corresponding for various portions of a software architecture. For example, a mobile device may correspond to a client and a cloud based service may correspond to a web service. Thus an architecture, software or hardware or both, may give rise to a generic classes of components, known as component types.

Functionally Equivalent (Semantics Preserving) Transformations, Automation, and Abstract Syntax Trees

Porting a software application involves porting the software application's source code. Typically source code is written in one or more programming languages, each programming language having its own grammar Early applications were written in a single programming language, such as FORTRAN or COBOL. Present enterprise applications are often written in multiple programming languages, often in the same source code file. For example, an application may use a structural language like Microsoft Visual Basic for procedures, but structured query language (“SQL”), for database access. By way of another example, web clients typically use some combination of hypertext markup language (“HTML”), cascading style sheets (“CSS”), and JavaScript.

As a result, in addition to porting to a different architecture, porting source code may involve transforming code expressed in multiple input grammars that represent the programming languages of the source code of the application to be ported, into code expressed in multiple output grammars representing the programming languages of the source code of the application after being ported. Enterprise applications, especially those that have been in operation for a relatively long time, are generally complex, may be large, and may be a hodge-podge of different programming languages and approaches as varied as the programmers who maintained the application.

Due to its complexity, porting an enterprise application is therefore a candidate program for computer automation. Specifically, the goal of a successful port is not only to achieve the architectural change and the translation across grammars, but also to preserve the semantics of the application's business logic after the porting process. That is to say, any invocation of the business logic post port should have the same behavior as prior to the port.

The emphasis on preserving semantics has the effect of de-emphasizing syntax. An automated approach to a port across architectures cannot be a naïve syntactic translation of the original components to the exact same components except in a different programming language. One approach to automating the porting process involves receiving input grammars and output grammars, developing a composite grammar, representing the application in an abstract syntax tree that supports the composite grammar. The abstract syntax tree may be annotated with transformational rules that impact either a node in the abstract syntax tree, all nodes in a sub-tree of the abstract syntax tree, or the entire abstract syntax tree. In this way, porting can be effected by traversing the abstract syntax tree and using the transformational rules in the annotations to determine what output code to generate.

The Notion of Code Separation

However, after a port, the architectural changes and grammar changes will change some of the functionality of original application vis-à-vis the ported application. At the very least, the ability to run on a new architecture constitutes a functional change. With an architectural change, components in the original application may not have a one to one correspondence with components in the ported application. Thus during a port, a decision is made as to which semantics are to be preserved.

Code separation is the process of identifying which portions of the source code of the original application map to different portions of a target architecture. Correctly separating code is the basis for a successful port. Consider the case where an application's client application was originally targeted for a personal computer but is being ported to a mobile phone. The user interfaces of the client applications will differ due to the form factor change. However both client applications should be able to expect that interactions with the business logic will be the same as in the original application. Therefore, separating code for the client from code for the business logic provides a basis for determining which semantics to preserve during a port.

Code Separation and Different Transformations

Code separation will have a varying role in an application port depending on the transformation to be achieved. A transformation is a deterministic alteration of source code to achieve a desired result. Since a transformation is achieved by the application of a deterministic algorithm, typically the transformation may be reversed by applying the inverse of the algorithm. However, transformations are not necessarily commutative.

Some transformations will not involve code separation. For example, a pure language port that does not involve an architectural change is less likely to use code separation. Language based changes such as compilation, or insertion of artifacts such as debug information, tend to preserve architecture.

However, other transformations will rely on code separation. In particular, changes in hardware architecture, such as porting from a single core computer processing unit (“CPU”) to a multi-core CPU, or to a system-on-a-chip (“SoC”), give rise to new hardware capabilities. Therefore the porting process will identify functionality in the original application that may take advantage of the new hardware. Similarly, porting software to a new framework, such as from COM to .NET, or to a new software architecture, such as a from two-tier client server to a web based services oriented architecture (“SOA”) is likely to rely on code separation since the component types in the original application will not have a one to one correspondence to the components types of the targeted architecture. In general, the greater the difference in architecture of the original application to the targeted architecture, the greater the reliance on code separation.

Differences in component types are not necessarily based on architecture. Some transformations, such as performance optimizations and code refactoring are not re-architecting transformations. For example, components may be combined into a single dynamic link library (“DLL”) to improve load times. Similarly, during refactoring, analysis may identify redundant code and consolidate functionality accordingly. Automated modifications to support a global business policy change in an application may also use code separation as some components likely to embody the policy may be assigned a distinct component type.

The Context of Code Separation with Semantic Guarantees

Having introduced code separation, we turn now to the automation of code separation. FIG. 1 is an exemplary context diagram 100 for code separation with semantic guarantees. Specifically, an automated software application transformation may be considered in terms of moving from concrete terms to abstract terms, as represented by the horizontal dotted line, and in terms of moving from pre-transformation, i.e., the original application, to post-transformation, i.e., the ported application.

Source code 102 comprises a concrete representation of the original application. Source code 102 is typically in the form of source code files and is generally written in one or more programming languages, each programming language represented by a grammar.

The source code 102 may be statically analyzed, and represented in an annotated abstract syntax tree 104, which supports the input grammars of the programming languages in the original application, as well as the output grammars of the programming languages in the targeted architecture. The annotations in the abstract syntax 104 tree represent transformational rules that impact either a node in the abstract syntax tree 104, all nodes in a sub-tree of the abstract syntax tree 104, or the entire abstract syntax tree 104. Thus code generation may be effected by a traversal of the abstract syntax tree 104 while applying the transformational rules.

However, code generation will also include separating code into components. Code separation starts with identifying candidate components 106 by querying the abstract syntax tree 104. A code separation function 108 analyzes the candidate components 106 in view of an architectural template describing the target architecture 110, i.e., the architecture the original application is being ported to, and transformational rules 112. Note that the transformational rules 112 may be part of the abstract syntax tree 104 or may be stored separately. The code separation process is described in more detail with respect to FIG. 3.

Once the code separation function 108 has identified how code from the original application is to be mapped to components in the target architecture, a code generation function 114 may commence. During the code generation, in additional to translation to new languages the components of the target architecture may be wrapped with code to facilitate operation in the target architecture, and may be connected to additional infrastructure elements, such as a runtime to optimize execution.

Exemplary Hardware Platform

FIG. 2 illustrates one possible embodiment of a hardware environment 200 for code separation with semantic guarantees.

Client device 202 is any computing device. A client device 202 may have a processor 204 and a memory 206. Client device 202's memory 206 is any computer-readable media which may store several programs including an application 208 and/or an operating system 210.

Computer-readable media includes, at least, two types of computer-readable media, namely computer storage media and communications media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information for access by a computing device. In contrast, communication media may embody computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave, or other transmission mechanism. As defined herein, computer storage media does not include communication media.

To participate in a communications environment, user equipment device 202 may have a network interface 212. The network interface 212 may be one or more network interfaces including Ethernet, Wi-Fi, or any number of other physical and data link standard interfaces. In the case where the programming language transformations are to be done on a single machine, the network interface 212 is optional.

Client 202 may use the network interface 212 to communicate to remote storage 214. Remote storage 214 may include network aware storage (“NAS”) or may be removable storage such as a thumb drive or memory stick.

Client 202 may communicate to a server 216. Server 216 is any computing device that may participate in a network. Client network interface 212 may ultimate connect to server 216 via server network interface 218. Server network interface 218 may be one or more network interfaces as described with respect to client network interface 212.

Server 216 also has a processor 220 and memory 222. As per the preceding discussion regarding client device 202, memory 222 is any computer-readable media including both computer storage media and communication media.

In particular, memory 222 stores software which may include an application 224 and/or an operating system 226. Memory 218 may also store applications 224 that may include a database management system. Accordingly, server 216 may include data store 228. Data store 228 may be configured as a relational database, an object-oriented database, and/or a columnar database, or any configuration to support policy storage.

Server 216 need not be on site or operated by the client enterprise. Server 216 may be hosted in a cloud 230. Cloud 230 may represent a plurality of disaggregated servers which provide virtual web application server 232 functionality and virtual database 234 functionality. Cloud 230 services 232, 234 may be made accessible via cloud infrastructure 236. Cloud infrastructure 236 not only provides access to cloud services 232, 234 but also billing services. Cloud infrastructure 236 may provide additional service abstractions such as Platform as a Service (“PAAS”), Infrastructure as a Service (“IAAS”), and Software as a Service (“SAAS”).

Example Operation of Performing a Software Application Transformation Using Code Separation with Semantic Guarantees

Software application ports are a form of software application transformation. Where the application architecture is to change, or where the application transformation gives rise to changes in component types, code separation techniques that preserve semantics are to be brought to bear. FIG. 3 illustrates a flowchart 300 of the example operation of performing a software application transformation using code separation with semantic guarantees.

In block 302, input comprising source code is received. Source code may be in the form of files written in one or more programming languages, each programming language represented in a grammar.

A code separation function may access the source code transformed into an abstract syntax tree that supports the input grammars of the source code of the original application as well as the output grammars of the target architecture, i.e., the architecture of the ported application. The abstract syntax tree may be annotated with transformational rules.

In block 304, an annotated abstract syntax tree is generated from at least one of the source code files of the original application. In this way, a port of a selected portion of the original application or a complete port of the entire original application may be effected.

In block 306, the code separation function receives an architectural template. The architectural template may describe a hardware architecture and/or a software architecture. The architectural template may describe solely the target software architecture, or may additionally describe a target platform comprising a target hardware architecture and support software such as an operating system, support libraries and/or frameworks, or an execution environment or virtual machine. In the case where the architectural template describes the target platform, the architectural template may also describe the advantages and disadvantages of the target platform. For example, where the target platform is distributed, the architectural template may indicate where performance may be degraded by network connections due to remote communications. By way of another example, the architectural template may indicate strong parallel processing capabilities, as in a server. In this way, the architectural template may provide input that may weigh the selection of components for a corresponding component type.

The architectural template will provide the basis for defining component types. For example, a software architecture may prescribe a client tier, a business logic tier, and a persistence tier. Each of these tier may represent a component type. Other software architectures include examples such as model-view-controller, model-view, and model-view-viewmodel. The specific example of model view viewmodel is discussed in more detail with respect to FIG. 5.

Alternatively, the architectural template may represent a business architecture instead, where each component type enumerates a function corresponding to the organization of the business enterprise such as departments and cost centers.

In the case of hardware architectures, the architectural template may describe a cloud infrastructure using a service oriented architecture accessed by mobile devices. The architectural template may include information about additional functionality present in the target cloud architecture such as that exposed by Platform as a Service, Infrastructure as a Service, and Software as a Service functionality.

In block 308, the existing transformational rules in the annotated abstract syntax tree are augmented with a generated set of transformational rules specific to the received architectural template. Example transformational rules would include the generation of wrapper code corresponding to the component types described in the architectural template. Wrapper code may include simple “plumbing” code that allows invocation in the new architecture. For example, components that were once local to each other may be transformed into remote components invoking each other via remote procedure call (“RPC”). Other transformation rules may include converting components from stateful to stateless components where they are to reside in a middle tier. In some cases, instead of wrapper code, a component may be transformed by invoking a platform element to optimize execution. Platform elements may include prebuilt platform rearchitecture agents containing code artifacts for the target platform. For example, the platform elements for a web page may include prebuilt hypertext markup language (“HTML”), cascading style sheet (“CSS”) and JavaScript files.

Note that it may be desirable for an architectural template to describe different transformation options for the same component type. For example, in a mobile device client scenario, a technician may desire to support both Apple iOS™ and Google Android™ embodiments of a client. In this case, components that have a client component type will have two sets of transformation rules, a first set corresponding to transforming the client components into an Apple iOS™ mobile client, and a second set corresponding to transforming the client components into a Google Android™ mobile client.

Not all transformation rules are driven by the architectural template. For example, the transformations translating the source code to the programming languages of the target architecture need not be generated from the architectural template.

Once the transformation rules specific to the architectural template are generated, the code separation function determines which components to apply those transformation rules. In block 310, the annotated abstract syntax tree is queried for candidate components. Candidate components are functional blocks with an invocation interface whose semantic behavior is guaranteed. The candidate components are inferred to be of a component type in the architectural template. Inferring candidate components to be of a specific component type is described in more detail with respect to FIG. 4.

Once the candidate components are associated with component types, in block 312, at least some candidate components are selected for transformation. In some cases, all the candidate components are selected. However, in other cases, a technician may be reviewing the candidate components via an integrated development environment (“IDE”) or some other development tool, and may opt to override the inferences made in block 310. Based on these selections, the abstract syntax tree may be further annotated with additional transformation rules, where these additional transformation rules are associated with the selected components. If the additional rules are added while a code generation is in progress, then the code generation may be reperformed via an IDE or development tool.

In general, an IDE or development tool provides the opportunity to monitor the status of a code generation in progress. For example, a log of operations against the abstract syntax tree, such as annotated, component identification, component type identification, and repositioning may be viewed. Particularly large and complex trees may take a relatively long time, thus the log may be viewed substantially in real time. Accordingly, an IDE or development tool may receive input from a technician to modify a code generation operation while in progress.

Where the IDE or development tool receives input from a technician, the components in the abstract syntax tree directly affected by the input are identified. Since the abstract syntax tree effectively stores information about components affected by other components changing, usually in the form as storing components in an affected component's subtree. Thus the IDE or development tool can identify all components dependent on components directly affected by a change. Thus if a code generation is in progress, code generation for the directly affected components as well as their dependent components may be reperformed. In this way, correct code may be generated despite an input change from a technician, without forcing a full code regeneration of the entire abstract syntax tree.

An IDE or development tool may access an arbitrary abstract syntax tree. Therefore, an IDE or development tool may manage transformations on different abstract syntax trees. Conversely, an abstract syntax tree may store as plurality of transformation rules for the same components in its annotations. For example, client components may be annotated with transformation rules to target a tablet or a personal computer at the same time, and the IDE or development tool will select which transformation rules to apply. In this way, an abstract syntax tree may be shared.

Upon selection, the application is ported by generating code in block 312. Specifically, the abstract syntax tree is traversed, and pretty printed according to the transformational rules. Code generation may include the generation of wrapper code as described above. Code generation may also include the generation of infrastructural elements to optimize execution. For example, it may be appropriate to generate a runtime, or a helper library specific to the target architecture.

Inferring Component Types During Code Separation

During code separation the code separation function infers which candidate components belong to a component type of the architectural template. Automated inference may be performed in a number of ways, but generally involves determining how similar a component is to a component type. FIG. 4 illustrates a flowchart of an exemplary embodiment inferring a component type during code separation.

In block 402, the code separation function receives an architectural template comprising one or more component types as described with respect to FIG. 3 above.

Recall that at this point, there is an abstract syntax tree that supports input grammars of the programming languages of an original software application and output grammars of the programming languages of the target architecture. The abstract syntax tree also represents a parsing or static analysis of at least some of the source code the original software application. Accordingly, the abstract syntax tree contains components comprised of a functional source code block with an invocation interface that guarantees the semantic behavior of the functional source code block.

Thus in block 404, the code separation function marks the components in the abstract syntax tree as at least one of the component types of the architectural template. This results in an abstract syntax tree with a number of candidate components. It also results in a number of candidate components that are not necessarily organized by component type, and therefore may need repositioning.

To perform the repositioning, in block 406, a distance function for component types is defined in terms of parameters comprising predetermined criteria. A distance function for component types provides a similarity score for component to a component type. The distance function typically supports a metric, for example a Euclidean distance. In this way, the distance function provides a way to perform deterministic sorting where the components are ordered monotonically, based on similarity to a component type. This ordering is performed in block 408 by a graph reaccommodation algorithm that uses the distance function as a metric. Specifically, the graph reaccommodation algorithm repositions components based on similarity to a component type.

One consequence of the ability to perform ordered sorting by component type is that the code separation function can identify the outer boundaries of each component type. Therefore, the invocation interfaces on the outer boundaries may be configured to guarantee semantics, and the interior components that do not face components from other component types may potentially be refactored without changing semantics. For example, a middle tier object having a business object component type that faces client objects might not change its invocation interface, but a business objects that face other business objects might be merged or otherwise modified.

The distance function may be a function of one or more predetermined criteria which allow the distance to be weighted. Examples include, but are not limited to: component similarity, component affinity, and component performance based on component proximity. For component similarity, the distance measure may directly calculate how similar a component is to a component type. For component affinity, the distance measure may modify the calculation how similar a component is to a component type based on similarity to other components known to belong to that component type. For example, a radio button may be classified as a client component type if it is measured as similar to a standard button which was beforehand classified as a client component with high confidence. For component performance, the distance measure may be modified in terms of performance metrics. For example, a stateless business object that would ordinarily be grouped with other middle tier objects might be placed instead with client objects to limit network round trips. Thus even though the stateless business object is classified as a business object and likely would be placed in a middle tier, the distance measure may be weighted to place stateless business objects closer to the client component type.

The predetermined criteria may be have been received with an architectural template. For example an architectural template may have enumerated the advantages and disadvantages of a target platform. Based on those advantages and disadvantages, the distance function may be weighed to favor one component type over another, based on the characteristics of a component. The advantages and disadvantages may not be specific to component type, but may indicate a change in operation, such as in a service oriented architecture, specifying that some objects should be stateless objects to facilitate scalability. Alternatively, the predetermined criteria may be independent of architecture, and not necessarily have been received with an architectural template. For example, business policies and enterprise standards may be specified as the predetermined criteria for the distance function.

There are several examples of graph reaccommodation algorithms. One example is simulated annealing. Simulated annealing is a well known algorithm where a large graph of objects may be organized. In the present example, the components comprise nodes in the graph, and the distance function defines the strength of connections between the nodes of the graph. The distance function is used to define a value to be tested for extrema (e.g. in this case typically a minima). After establishing an initial positioning, and the extrema value, the simulated annealing function iterates through potential repositionings. Where a repositioning improves the extrema value (e.g. a lower value is discovered if testing for minima), the repositioning is replaces the prior positioning. When a predetermined threshold is satisfied, for example a time limit or a desired extrema threshold, the simulated annealing iteration stops. The components in the abstract syntax tree are then repositioned according to the final positioning determined by the simulated annealing algorithm.

Another example of a graph reaccommodation algorithm is to use develop a lattice comprising multiple dimensions, each dimension corresponding to a component type. Components are then placed in the lattice according to similarity to the component type. A force function describing affinity between the components is then described. A first repositioning is then effected by first applying the force function to determine the degree of repulsion between the components. A second repositioning is then effect by then applying the force function to determine the degree of attraction between the components. The result is a repositioning of the components where components of similar component type aggregate.

In general, the where the overall ordering of a system may be represented based on component distances based on the distance function, the system may be deterministically reordered such that the components aggregate to their likely component types. One may consider variations on linear programming where a tableau describing the graph of components may be pivoted to a desired extrema. Accordingly, this patent application describes various graph reaccommodation techniques without loss of generality.

Regardless of the graphic reaccommodation algorithm used, or the distance function used, once the candidate components are repositioned, in block 410 the code separation algorithm may infer which candidate components have which component types based on the repositioning. At this point, the repositioned abstract syntax tree is ready for code generation as described with respect to FIG. 3 above.

Example Use Cases

The aforementioned code separation techniques may be used for a number of transformations. By way of example, a typically application is to port a legacy client-server application to a web based service oriented architecture (“SOA”).

In this example, the server portion of the client-server application is hosted on a web infrastructure such as a cloud infrastructure. The client application may continue to be accessible via a personal computer, but as a web application. Furthermore, the client application may also be ported to various tablet targets and/or mobile phone targets.

A typical software architecture is the model-view-viewmodel, which is used as the target architecture. Therefore, component types of model, view, and viewmodel are derived from the target architecture. Roughly speaking, the model may be the client side local data model, such as an extensible markup language (“XML”) data island. The view may correspond to a client hypertext markup language (“HTML”) and cascading style sheet (“CSS”) client with embedded JavaScript that accesses the XML data island. Finally, the viewmodel may be a server side web service that serves the data island. FIG. 5 illustrates a flowchart of an exemplary embodiment of code separation with semantic guarantees in a port to a model-view-viewmodel target architecture.

As described with respect to FIG. 3 above, source code for a software application may be parsed or statically analyzed to generate one or more abstract syntax trees that capture the semantic and syntactic elements of the source code. In the present MVVM example, we assume the software application is written using an application framework that includes one or more user interface container classes. For example, .NET™ may include a Windows Form, and the Microsoft Foundation Classes™ include Dialog Box, Form, and Window and Document-View classes. In block 502, one or more abstract syntax trees for the software application are received.

In block 504, an architectural template specifying a front-end component type and a back-end component type is received. In the present example, the model-view portion of the target architecture corresponds to the front-end component type and the viewmodel portion of the target architecture corresponds to the back-end component type. Other mappings may exist. For example a view-controller portion of a model-view-controller architecture may correspond to the front-end component type and the model portion may correspond to the back-end component type. Thus while the present example is directed to MVVM architectures, other architectures with a front-end component type and a back-end component type are supported without loss of generality.

In block 506, the abstract syntax trees are traversed or otherwise queried for all instances of components that are a user interface container class in the application framework. Those components are then typed as front-end component types.

In block 508, the identified user interface container components are iterated. For each user interface container component, all components contained by the container class are grouped together. In block 510, a respective back-end component set is created. At this point, the back-end component set starts as an empty set.

In block 512, the components contained by the container class are iterated through. As each component is iterated in block 514, the code separation function seeks back-end indicia for the component in block 516. If back-end indicia are detected, then in block 518, the component is added to the respective back-end component set and the component type is changed to back-end component type. Otherwise, in block 520, the next component is retrieved. If the iteration is complete, then execution proceeds to block 522.

There are a number of back-end indicia. For example, the attributes of a component may be reviewed for references. If the references are made solely by business logic or persistence functions, then the component may be likely to be a back-end component. Framework class type may also assist. Many classes in an application framework are known to be either front-end or back-end types. Accordingly, the application framework type may be indicia of being a back-end component type (or not being a back-end component type). In other situations, a component may be compared to another component known to be a back-end component type. Where the similarity satisfies a predetermined threshold, the component may be determined to be a back-end component type.

The foregoing is not intended to be an exhaustive list of back-end indicia. Where an IDE or development tool is used in the code separation process, a technician may identify new heuristics or back-end indicia, and may modify the code separation process accordingly.

In block 522 the code separation function determines whether there is another user class component to iterate. If there is, then execution returns to block 508. Otherwise, execution continues to a next phase in block 524. At this point, after execution, the components are now typed either as front-end component types or as back end component types, completing the component type inference such as in block 310 of FIG. 3.

CONCLUSION

Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. 

What is claimed is:
 1. A method to perform a software application transformation comprising: receiving at least one input file of the software application in at least one programming language, wherein the at least one programming language is represented in at least one grammar; receiving an architectural template of a target platform for executing code that results from transformation of the software application, wherein the architectural template specifies at least one component type; generating a set of transformation rules based at least on the received architectural template for the target platform; generating an annotated abstract syntax tree from the at least one input file, wherein the annotations in the annotated abstract syntax tree include the set of transformation rules generated from the received architectural template of the target platform and one or more additional transformational rules that are unrelated to not generated from the received architectural template of the target platform; inferring a plurality of candidate components from the annotated abstract syntax tree based at least on the at least one component type of the received architectural template; selecting multiple candidate components of the plurality of candidate components to be transformed; and generating the code for the target platform by traversing the abstract syntax tree to restructure the multiple candidate components into separate component types.
 2. The method of claim 1, wherein the multiple candidate selected components are transformed by at least one of the following: wrapping with wrapper code for a target architecture; and connecting with at least one additional infrastructure element to optimize execution.
 3. The method of claim 1, wherein the architectural template describes candidate components in terms of a software architecture.
 4. The method of claim 3, wherein the software architecture includes any one of the following: model-view; model-view-controller; and model-view-viewmodel.
 5. The method of claim 3, wherein the architectural template describes a cloud infrastructure.
 6. The method of claim 5, wherein the cloud infrastructure includes any one of the following: Platform as a Service; Infrastructure as a Service; and Software as a Service.
 7. The method of claim 3, wherein the architectural template describes either a business architecture or a service oriented architecture.
 8. The method of claim 1, wherein the transformational rules include any one of the following: component specific rules; rules specific to one or more candidate components positioned in a sub-tree of the abstract syntax tree; rules specific to one or more candidate components satisfying a predetermined condition; business specific rules; service oriented architecture specific rules; and rules global to the multiple candidate components.
 9. The method of claim 1, wherein the transformational rules comprise rules that define a plurality of transformations for one or more candidate components of a component type.
 10. The method of claim 9, wherein the plurality of transformations cover a plurality of platforms respectively.
 11. The method of claim 1, wherein the component types of the received architectural template characterize a candidate component according to an optimal placement of the candidate component in the architectural template, and wherein inferring a plurality of candidate components comprises: marking at least two candidate components in the abstract syntax tree according to a plurality of component types from the architectural template; defining a distance function between the plurality of component types with parameters comprising predetermined criteria; performing a repositioning of the at least two candidate components based on a graph reaccomodation algorithm that uses a distance calculation from the distance function to determine a new positioning; and inferring corresponding component types of the plurality of candidate components based at least on the repositioning of the at least two candidate components.
 12. The method of claim 11, wherein the parameters comprising predetermined criteria include any one of: component similarity, component affinity, an relationship of component types in a target architecture, and component performance based on component proximity.
 13. The method of claim 11, wherein the architectural template comprises advantages and disadvantages of a platform in a target architecture, and wherein the predetermined criteria include the advantages and disadvantages of a platform in the target architecture.
 14. The method of claim 11, wherein the graph reaccomodation algorithm is a simulated annealing algorithm.
 15. The method of claim 11, further comprising providing a status report for the generating of the code for the target platform.
 16. The method of claim 15, wherein the status report is updated substantively in real time.
 17. The method of claim 11, wherein the component types comprise client, business logic and persistence.
 18. The method of claim 1, wherein the selecting the multiple candidate components includes selecting based on a user input from a user.
 19. The method of claim 18, wherein the user input is received during a code generation in progress.
 20. The method of claim 19, wherein the user input includes a modification to a candidate component repositioned by a graph reaccommodation algorithm.
 21. The method of claim 1, further comprising: receiving a user input that selects at least one new candidate component from the plurality of candidate components to be transformed; regenerating a portion of the code based at least on a portion of the abstract syntax tree affected by the user input.
 22. A method to perform a software application transformation comprising: receiving at least one abstract syntax tree comprising semantic and syntactic elements of a source code of a software application, the semantic and syntactic elements representing an application framework that includes a set of user interface container classes; receiving an architectural template specifying a front-end component type and a back-end component type; identifying a plurality of components in an input file of a software application as that are user interface container class components by traversing the one or more abstract syntax trees and typing the plurality of components as having front-end component types; and for each identified user interface container class component: creating an empty respective back-end component set, identifying the identified user interface container class component as a particular user interface container class component and initially typing the identified user interface container class component as having a particular front-end component type, and adding the identified user interface container class component to the empty respective back-end component set, and changing the particular front-end component type to a back-end component type in response to determining that the identified user interface container class component has one or more indicia of being associated with the back-end component type.
 23. The method of claim 22, wherein the indicia of being associated with a back-end component type includes any one of the following: component attributes of the identified user interface container class component are solely referenced by business logic; the identified user interface container class component is in a framework type affirmatively known to be the back-end component type; and the identified user interface container class component has a similarity to another component in the input file that is known to be the back-end component type.
 24. A method to perform a software application transformation comprising: receiving at least one input file of the software application in a programming language, the programming language being represented in at least one grammar; receiving an architectural template of a target platform, wherein the architectural template comprises at least one component type; generating a first set of transformational rules based on the at least one component type of the received architectural template, the first set of transformational rules including a transformational rule for converting a component of the software application into a transformed component; generating an annotated abstract syntax tree from the at least one input file and the first set of transformational rules that are generated based on the at least one component type of the received architectural template of the target platform; generating a second set of transformational rules; modifying the generated annotated abstract syntax tree based on the generated second set of transformational rules.
 25. The method of claim 24, wherein the generated abstract syntax tree is a shared tree.
 26. The system of claim 25, wherein the abstract syntax tree transformer is to generate the at least one transformed component based at least on the input requested from the technician by the software user interface.
 27. A system to perform a software application transformation comprising: a processor; memory, communicatively coupled to the processor, the memory storing elements executable by the one or more processors, the elements comprising: a software user interface resident to specify source code files of a software application, to specify one or more grammars, to specify a target architecture, and to request an input from a technician; a transformation rules generator to generate transformation rules based at least on the specified target architecture, wherein the specified target architecture comprises at least one component type; an abstract syntax tree generator to generate an annotated abstract syntax tree based on at least one specified source code file, at least one specified grammar, and at least one transformation rule that is generated based at least on the specified target architecture; a component recommendation engine to identify candidate components according to the at least one component type of the specified target architecture; and an abstract syntax tree transformer to generate at least one transformed component from one or more of the candidate components.
 28. A computing system to perform a software application transformation, comprising: a processor; memory, communicatively coupled to the processor containing computer readable instructions to perform acts comprising: receiving at least one source file of an software application in at least one programming language, wherein the at least one programming language is represented in at least one grammar; receiving an architectural template of a target platform, wherein the architectural template specifies at least one component type; generating a set of transformation rules for transforming components of the software application into code for the target platform based at least on the received architectural template of the target platform; generating an annotated abstract syntax tree from the at least one source file, wherein the annotations in the annotated abstract syntax tree include the set of generated transformation rules that are generated based at least one the received architectural template of the target platform and one or more additional transformational rules, the annotated abstract syntax tree for transforming components of the software application into code for the target platform, the one or more additional transformation rules being unrelated to the received architectural template; inferring a plurality of candidate components from the annotated abstract syntax tree based at least on the at least one component type of the received architectural template; selecting multiple candidate components to be transformed from the plurality of candidate components; and generating the code for the target platform by traversing the abstract syntax tree wherein, the multiple selected candidate components are separated into separate components, and wrapped with wrapper code for the target platform, and connected with at least one additional infrastructure element to optimize execution of the code. 